﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml.Serialization;

namespace ERPStore.Settings
{
	/// <summary>
	/// Informations de configuration du site web
	/// </summary>
	[Serializable]
	public class WebSiteSettings
	{
		/// <summary>
		/// Initializes a new instance of the <see cref="WebSiteSettings"/> class.
		/// </summary>
		public WebSiteSettings()
		{
			PrivateMode = false;
			Contact = new ContactSettings();
			Payment = new Settings.PaymentSettings();
			Shipping = new ShippingSettings();
			Catalog = new CatalogSettings();
            ApiToken = Guid.NewGuid().ToString();
			CountryId = Models.Country.Default.Id;
			LanguageId = Models.Language.French.Id;
			Emailer = new EmailerSettings();
			Format = new FormatSettings();
			Registration = new RegistrationSettings();
		}

		/// <summary>
		/// Nom du site web
		/// </summary>
		/// <value>The name of the site.</value>
		public string SiteName { get; set; }

		/// <summary>
		/// Nom de l'application (sans espace)
		/// </summary>
		public string ApplicationName { get; set; }

		[System.Xml.Serialization.XmlIgnore]
		public byte[] Version { get; set; }

		/// <summary>
		/// Clé de l'api d'administration du site a partir 
		/// d'ERP360
		/// </summary>
		/// <value>The API token.</value>
		public string ApiToken { get; set; }

		/// <summary>
		/// Url complète du logo de la forme http://www.site.com/logo.png
		/// </summary>
		public string LogoFullUrl { get; set; }

		/// <summary>
		/// Emplacement physique du site
		/// </summary>
		/// <value>The path.</value>
		[System.Xml.Serialization.XmlIgnore]
		public string PhysicalPath { get; set; }

		/// <summary>
		/// Repertoire temporaire
		/// </summary>
		[System.Xml.Serialization.XmlIgnore]
		public string TempPath { get; set; }

		/// <summary>
		/// Répertoire contenant les images
		/// </summary>
		[System.Xml.Serialization.XmlIgnore]
		public string ImagePath { get; set; }

		/// <summary>
		/// Repertoire des documents fichier
		/// </summary>
		/// <value>The document path.</value>
		[System.Xml.Serialization.XmlIgnore]
		public string DocumentPath { get; set; }

		/// <summary>
		/// Clé de crypage (Key)
		/// </summary>
		public byte[] CryptoKey { get; set; }

		/// <summary>
		/// Clé de cryptage (IV)
		/// </summary>
		public byte[] CryptoIV { get; set; }

		/// <summary>
		/// Indique l'url en cours
		/// </summary>
		/// <value>The URL.</value>
		[System.Xml.Serialization.XmlIgnore]
		public string CurrentUrl { get; set; }

		/// <summary>
		/// Url par défaut
		/// </summary>
		public string DefaultUrl { get; set; }

		/// <summary>
		/// Url pour la couche de service WebApi
		/// </summary>
		public string ServiceUrl { get; set; }

		/// <summary>
		/// Pays du site.
		/// </summary>
		/// <value>The country.</value>
		[XmlIgnore]
		public Models.Country Country 
		{
			get
			{
				return ERPStore.Models.Country.GetByKey(CountryId);
			}
		}

		public int CountryId { get; set; }

		[XmlIgnore]
		public ERPStore.Models.Language Language
		{
			get
			{
				return ERPStore.Models.Language.GetByKey(LanguageId);
			}
		}

		public int LanguageId { get; set; }

		/// <summary>
		/// Numéro de déclaration à la CNIL
		/// </summary>
		/// <value>The cnil number.</value>
		public string CnilNumber { get; set; }

		/// <summary>
		/// Mode d'affichage du site 
		/// si true, active le filtre des pages privée
		/// (lecture d'un fichier d'autorisation, different par client)
		/// </summary>
		public bool PrivateMode { get; set; }

		/// <summary>
		/// Portée du cookie principal sur le domaine
		/// Laisser vide si tout le domaine est utilisé
		/// </summary>
		public string CookieDomain { get; set; }

		/// <summary>
		/// Nombre de jours avant l'expiration du cookie
		/// </summary>
		public int? CookieExpirationDelayInDays { get; set; }

		/// <summary>
		/// Configuration des informations de contact
		/// </summary>
		/// <value>The contact.</value>
		public ContactSettings Contact { get; set; }

		/// <summary>
		/// Configuration des modes de reglement
		/// </summary>
		/// <value>The payment.</value>
		public PaymentSettings Payment { get; set; }

		/// <summary>
		/// Paramètres de livraison
		/// </summary>
		/// <value>The shipping.</value>
		public ShippingSettings Shipping { get; set; }

		/// <summary>
		/// Paramètres du catalogue
		/// </summary>
		/// <value>The catalog.</value>
		public CatalogSettings Catalog { get; set; }

		/// <summary>
		/// Paramètres de configuration des vues razor pour les emails
		/// </summary>
		/// <value>The emailer settings.</value>
		public EmailerSettings Emailer { get; set; }

		/// <summary>
		/// Configuration du formatage
		/// </summary>
		public FormatSettings Format { get; set; }

		/// <summary>
		/// Configuration de l'enregistrement d'un client
		/// </summary>
		public RegistrationSettings Registration { get; set; }
	}
}